<template>
  <div>
    <el-container>
      <el-header>logo</el-header>
      <el-main>
        <el-row :gutter="20">
          <el-col :span="12" :offset="6">
            <div class="grid-content bg-purple">
              <el-input v-model="signin_info.username" placeholder="用户名"></el-input>
              <el-input placeholder="请输入密码" v-model="signin_info.password" show-password></el-input>
              <el-button type="primary" @click="signin">登陆</el-button>
            </div>
          </el-col>
        </el-row>
      </el-main>
      <el-footer>网站信息</el-footer>
    </el-container>
  </div>
</template>

<script>
// get post put  delete 
// restful api
export default {
  name: "SignIn",
  data() {
    return {
      signin_info: {
        username: "admin",
        password: ""
      }
    }
  },
  methods: {
    signin() {
      this.$axios.post(
        "/api/signin",
        JSON.stringify(this.signin_info)
      ).then(response => {
        if (response.data.code == 200) {

          this.$message({
            message: "登陆成功",
            type: "success"
          });

          this.$router.push("/");
        } else {
          this.$message({
            message: response.data.message,
            type: "error"
          });
        }
      });
    }
  }
};
</script>

<style scoped>
.el-col {
  padding: 0;
}
.grid-content {
  margin-top: 20%;
  height: 70%;
  background-color: #fff;
}
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
  height: 15vh;
}

.el-main {
  background-color: #fff;
  color: #333;
  text-align: center;
  padding: 0;
  width: 100vw;
  height: 87.5vh;
  background-image: url("../../public/images/bg.png");
  background-size: cover;
}

body > .el-container {
  margin-bottom: 40px;
  height: 100%;
}
</style>
